package com.buct.coder.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.buct.coder.facade.request.PageRequest;
import com.buct.coder.facade.response.ApiResult;
import com.buct.coder.model.StudentWorkInfo;
import com.buct.coder.service.IStudentWorkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学生做题统计表 前端控制器
 * </p>
 *
 * @author xinzi
 * @since 2022-08-18
 */
@RestController
@RequestMapping("/work")
public class StudentWorkInfoController {

    @Autowired
    private IStudentWorkInfoService studentWorkInfoService;

    @PostMapping("/{stuId}/list")
    public ApiResult<Page<StudentWorkInfo>> findPages(@PathVariable("stuId") Long stuId, @RequestBody PageRequest pageRequest) {
        return ApiResult.success(studentWorkInfoService.page(
                new Page<>(pageRequest.getPage(), pageRequest.getSize()),
                new LambdaQueryWrapper<StudentWorkInfo>().eq(StudentWorkInfo::getStuId, stuId)
        ));
    }

}
